A shader is a program that executes on a graphics card to produce a range of visual effects on a display. Modern video games use shaders to render different materials on screen during gameplay (e.g., a matte material, a shiny material, etc.). When these programs are executed in a graphics pipeline, the shaders output per-pixel values (e.g., color values) that are combined to create an image on the display with a desired visual effect.
A game developer may write source code for shaders in a high-level programming language, such as High Level Shading Language (HLSL), OpenGL Shading Language (GLSL), or a similar programming language, and this source code is then compiled into a byte code representation of the shaders. Before shaders can be executed on a graphics card, however, the shaders are further compiled into machine code that is executable by a graphics processing unit (GPU) of the client machine. In other words, when a customer runs the game for the first time on his/her client machine, the graphics driver loads the byte code associated with the shaders, and compiles the byte code into machine code that is executable by the specific GPU of the client machine. This final shader compilation process results in compiled shader code that is unique to the hardware configuration of the client machine (e.g., unique to the GPU model and/or the version of the graphics driver). Because most game developers want their video games to execute on Personal Computer (PC) platforms with different hardware configurations, the game developer often distributes the shaders to customers in byte code format, leaving the shader compilation process to be performed at runtime on the client machine so that the particular graphics driver can compile the shader into the correct machine code for the hardware configuration in question. Console video games, by contrast, are shipped with machine code for the shaders that has already been compiled from byte code and is ready to execute by the GPU of the console. This is because the hardware configuration of the console is known to the game developer.
On a PC platform, if the shaders are compiled when the video game is loading on the client machine, the initial loading screen for the game can be presented for an undesirably long time (e.g., several minutes). This is because when the game is loading, the graphics driver will compile all of the shaders for the game's data set to create the machine code that is executable by the GPU during gameplay. Alternatively, if a game developer designs a game to compile shaders during gameplay, whenever a new material is encountered for the first time, the graphics driver will compile the shader for that material into machine code, which can take some time, potentially causing in-game stuttering or hitching (a condition where the graphics driver spends too much time compiling a shader into machine code and cannot render frames at a fast enough rate). Thus, compiling shaders locally on the client machine can result in long load times and/or in-game stuttering. Provided herein are technical solutions to improve and enhance these and other systems.